package com.tripwego.client.ui.pageVoyage.cr;

import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.dom.client.HasClickHandlers;
import com.google.gwt.event.shared.HandlerRegistration;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
import com.google.gwt.user.client.ui.HasVerticalAlignment;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.Label;

public class CRTitleWidget extends Composite implements HasClickHandlers {

	/*
	 * Elements graphiques
	 */
	private FlexTable viewPanel = new FlexTable();

	private Label lblTitle = new Label("Carnet de route");

	private Image image = new Image("icons/prev.png");

	/**
	 * 
	 */
	public CRTitleWidget() {
		super();
		viewPanel.setBorderWidth(0);

		viewPanel.setStyleName("CRTitleWidget");
		viewPanel.setSize("350px", "");

		viewPanel.setWidget(0, 0, lblTitle);
		viewPanel.getCellFormatter().setWidth(0, 0, "1%");
		lblTitle.setWidth("1%");
		lblTitle.setWordWrap(false);
		lblTitle.setStyleName("lblCRHover");

		initWidget(viewPanel);

		viewPanel.setWidget(0, 1, image);
		viewPanel.getCellFormatter().setHeight(0, 1, "");
		viewPanel.getCellFormatter().setWidth(0, 1, "");
		viewPanel.getCellFormatter().setHorizontalAlignment(0, 1, HasHorizontalAlignment.ALIGN_RIGHT);
		viewPanel.getCellFormatter().setVerticalAlignment(0, 1, HasVerticalAlignment.ALIGN_MIDDLE);
		viewPanel.getCellFormatter().setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_LEFT);
		viewPanel.getCellFormatter().setVerticalAlignment(0, 0, HasVerticalAlignment.ALIGN_MIDDLE);

		image.setTitle("Masquer le Carnet de route");
	}

	@Override
	public HandlerRegistration addClickHandler(ClickHandler handler) {
		return addDomHandler(handler, ClickEvent.getType());
	}

}
